package com.moxiao.yfjh.module.maker.common;

import com.moxiao.yfjh.module.blind.common.NotifyMessageEnum;
import com.moxiao.yfjh.module.blind.controller.admin.notifymessage.vo.BlindNotifyMessageCreateReqVO;
import com.moxiao.yfjh.module.blind.service.notifymessage.BlindNotifyMessageService;
import com.moxiao.yfjh.module.maker.controller.admin.matchMakerStringing.vo.MatchmakerStringingCreateReqVO;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @version 1.0
 * @Author zhk
 * @Date 2024/2/20 17:12
 **/
@Component
public class MakerNotifyMessageUtils {


    @Resource
    private BlindNotifyMessageService blindNotifyMessageService;

    /**
     * 红娘牵线：红娘给进行牵线后触发=主动发起的牵线人
     *
     * @param createReqVO
     */
    public void createMessage(MatchmakerStringingCreateReqVO createReqVO, String rceive_user_name) {

        BlindNotifyMessageCreateReqVO blindNotifyMessageCreateReqVO = new BlindNotifyMessageCreateReqVO();
        blindNotifyMessageCreateReqVO.setUserId(String.valueOf(createReqVO.getActiveId()));
        blindNotifyMessageCreateReqVO.setMessageType(NotifyMessageEnum.MAKER_STRINGING_MEMBER_USER.getType());
        String context = NotifyMessageEnum.MAKER_STRINGING_MEMBER_USER.getContext();
        String format = String.format(context, rceive_user_name);
        blindNotifyMessageCreateReqVO.setContent(format);
        String jumpUrl = NotifyMessageEnum.MAKER_STRINGING_MEMBER_USER.getJumpUrl();
        blindNotifyMessageCreateReqVO.setJumpUrl(String.format(jumpUrl, createReqVO.getManId()));
        blindNotifyMessageCreateReqVO.setReadStatus(0);
        blindNotifyMessageCreateReqVO.setStatus((byte) 4);
        blindNotifyMessageCreateReqVO.setTitle("红娘通知");
        blindNotifyMessageService.createNotifyMessage(blindNotifyMessageCreateReqVO);

    }

    /**
     * 红娘牵线：红娘给进行牵线后触发=被动牵线人
     *
     * @param createReqVO
     */
    public void createReceiveMessage(MatchmakerStringingCreateReqVO createReqVO, String active_user_name) {
        BlindNotifyMessageCreateReqVO blindNotifyMessageCreateReqVO = new BlindNotifyMessageCreateReqVO();
        blindNotifyMessageCreateReqVO.setUserId(String.valueOf(createReqVO.getReceiveId()));
        blindNotifyMessageCreateReqVO.setMessageType(NotifyMessageEnum.MAKER_STRINGING_RECEIVE_MEMBER_USER.getType());

        String context = NotifyMessageEnum.MAKER_STRINGING_RECEIVE_MEMBER_USER.getContext();
        String format = String.format(context, active_user_name);
        blindNotifyMessageCreateReqVO.setContent(format);

        String jumpUrl = NotifyMessageEnum.MAKER_STRINGING_RECEIVE_MEMBER_USER.getJumpUrl();
        blindNotifyMessageCreateReqVO.setJumpUrl(String.format(jumpUrl, createReqVO.getManId()));
        blindNotifyMessageCreateReqVO.setReadStatus(0);
        blindNotifyMessageCreateReqVO.setStatus((byte) 4);
        blindNotifyMessageCreateReqVO.setTitle("红娘通知");
        blindNotifyMessageService.createNotifyMessage(blindNotifyMessageCreateReqVO);
    }

}
